/*
 * CompanyData.cpp
 *
 *  Created on: Mar 25, 2014
 *      Author: Alexander
 */

#include "CompanyData.h"
#include <iostream>

#include <Poco/StringTokenizer.h>
#include <Poco/String.h>
#include <Poco/NumberParser.h>
#include <Poco/DateTimeParser.h>
#include <Poco/DateTime.h>
#include <Poco/RegularExpression.h>

#include <global.h>

CompanyData::CompanyData (const std::string& ticker, const std::string& exchange, const std::string& name,
		double lastQuote, double marketCap, const std::string& sector, const std::string& industry,
		const std::string& summary, bool isValid) :
		ticker_ (ticker), exchange_ (exchange), name_ (name), lastQuote_ (lastQuote), marketCap_ (marketCap), sector_ (sector),
		industry_ (industry), summaryQuote_ (summary), isValid_(isValid)
{ }

void CompanyData::showCompanyInfo() const
{
	std::cout << "Ticker: " << ticker_ << std::endl;
	std::cout << "Exchange: " << exchange_ << std::endl;
	std::cout << "Name: " << name_ << std::endl;
	std::cout << "Last Quote: " << lastQuote_ << std::endl;
	std::cout << "Market Capitalization: " << marketCap_ << std::endl;
	std::cout << "Sector: " << sector_ << std::endl;
	std::cout << "Industry: " << industry_ << std::endl;
	std::cout << "Summary Quote: " << summaryQuote_ << std::endl;

	std::cout << "----------" << std::endl;
	std::cout << "Income Statement: " << std::endl;
	for (auto a : incomeStatement_)
	{
		for (auto b : a.second)
		{
			std::cout << a.first << " (" << b.first << "): " << b.second << std::endl;
		}
	}
	std::cout << "----------" << std::endl;
	std::cout << "Balance Sheet: " << std::endl;
	for (auto it = balanceSheet_.begin(); it != balanceSheet_.end(); ++it)
	{
		for (auto year_it = it->second.begin(); year_it != it->second.end(); ++year_it)
		{
			std::cout << it->first << " (" << year_it->first << "): " << year_it->second << std::endl;
		}
	}
	std::cout << "----------" << std::endl;
	std::cout << "Cash Flow: " << std::endl;
	for (auto it = cashFlow_.begin(); it != cashFlow_.end(); ++it)
	{
		for (auto year_it = it->second.begin(); year_it != it->second.end(); ++year_it)
		{
			std::cout << it->first << " (" << year_it->first << "): " << year_it->second << std::endl;
		}
	}
	std::cout << "----------" << std::endl;
	std::cout << "Financial Ratios: " << std::endl;
	for (auto it = finRatios_.begin(); it != finRatios_.end(); ++it)
	{
		for (auto year_it = it->second.begin(); year_it != it->second.end(); ++year_it)
		{
			std::cout << it->first << " (" << year_it->first << "): " << year_it->second << std::endl;
		}
	}
	std::cout << "----------" << std::endl;
	std::cout << "Key Statistics: " << std::endl;
	for (auto it = keyStatistics_.begin(); it != keyStatistics_.end(); ++it)
	{
		std::cout << it->first << ": " << it->second << std::endl;
	}
}

//void CompanyData::setIncomeStatement(std::map<std::string, std::map<std::string, float>>& is)
//{
//	incomeStatement_ = is;
//}

void CompanyData::setBalanceSheet(std::map<std::string, std::map<std::string, float>>& bs)
{
	balanceSheet_ = bs;
}

void CompanyData::setCashFlow(std::map<std::string, std::map<std::string, float>>& cf)
{
	cashFlow_ = cf;
}

void CompanyData::setFinancialRatios(std::map<std::string, std::map<std::string, float>>& fr)
{
	finRatios_ = fr;
}

void CompanyData::setKeyStatistics(std::map<std::string, float>& ks)
{
	keyStatistics_ = ks;
}
